// d:\zhongheng\shenye-dy-applet\pages\indexMap\indexMap.js
const app = getApp()
import {
  getRoutesByArea,
} from '../../api/indexMap'
const handleAuthorize = require('../../utils/handleAuthorize')
Page({
  data: {
    addrList: [],
    isToken: false,
    istalent: 0,//判断用户是否是达人 0 不是 1 是
  },
  onLoad: function (options) {
    // tt.setStorageSync('token', 'Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJkYXRhIjoiM2hMM0RSRFlVUVdUNTNQTGFrM2MzdExqR3VpUE5vbWhaSytheXNjcnlNeldUbnpsNFVZVm1oZXpVTis5Y3hkUiJ9.BU2CZUiY5_eJx9f0ftSBhGYuUI_-QH6HWhIwkKIYMcg');
    this.setData({
      isToken: handleAuthorize.validate_login()
    })
    // this.getRoutesByArea()
  },
  onShow(){
    this.getRoutesByArea()
  },
  //地址
  async getRoutesByArea() {
    let res = await getRoutesByArea()
    this.setData({
      addrList: res.result
    })
  },
  //添加足迹
  handleAdd(){
    var isToken = this.data.isToken
    if(isToken){
      if(this.data.istalent == 1){
        tt.navigateTo({
          url: '/pages/subPackages/pagesA/creatingVideosSetUpBackup/creatingVideosSetUpBackup',
        });
      }else{//不是达人
        tt.showToast({
          title: '您当前无权限发布作品',
          icon: 'none',
        });
      }
    }else{
      const childComponent = this.selectComponent('#loginPopupId');
      childComponent.openPopup();
    }
  },
   // 取消登录
   cancelFunc(){

   },
   // 确认登录
   confirmFunc(){
     handleAuthorize.jumpPublicLogin()
   },
   //跳转足迹
   handleList(e){
    let code = e.currentTarget.dataset.code
    tt.navigateTo({
      url: '/pages/subPackages/pagesA/footprint/footprint?code='+code,
    });
   },
   onShareAppMessage(shareOption) {
    console.log(shareOption);
      return {
        channel: "video",
        extra: {
          withVideoId: true,
        },
        success: (res) => {
          console.log("分享成功");
          console.log("res",res);
        },
      };
    },
})